package Servlet;
import Shiti.Userti;
import service.Userservice;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;
import java.io.IOException;
import java.io.PrintWriter;
@WebServlet("/AddUserservlet")
public class AddUserservlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;utf-8");
        response.setCharacterEncoding("utf-8");
        PrintWriter out = response.getWriter();
        int acc= Integer.parseInt(request.getParameter("acc1"));
      String psw = request.getParameter("psw1");
      String name =request.getParameter("name1");
        Userti userti=new Userti(acc,psw,name);
        Userservice userservice=new Userservice();
        boolean a=userservice.zhuce(userti);
        if (a) {
            request.getRequestDispatcher("/Usergongneng.jsp").forward(request,response);
        }else {
            out.println("注册失败");
        }
    }
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
